package container

import (
	"os"
	"os/exec"
)

// Container container
type Container struct {
	workDir string
	cmd     *exec.Cmd
}

// New create container
func New(name string, args ...string) *Container {
	cmd := exec.Command(name, args...)
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	return &Container{
		cmd: cmd,
	}
}

// Init initialize container
func (c *Container) Init() error {
	os.Remove("/dev/null")
	os.Remove("/dev/zero")
	os.Remove("/dev/urandom")
	os.Remove("/dev/random")
	return c.initMount()
}

// Run run container
func (c *Container) Run() error {
	return c.cmd.Run()
}
